< previous page page_216 next page >

Page 216
Let's say that the phone book entry was "MyISP." When the list box was loaded, it was set to the string "MyISP" followed by a NULL character. But that NULL character is not stored in the list box! Why? Because the list control, like most Windows controls, is written in C and uses C strings. So it stripped off the NULL termination character when the string was stored in the list box.
What happens when you assign a 5-character string to a 257-character fixed-length string? Visual Basic loads the rest of the string with spaces! When the API function tries comparing the phone book entry with a string containing the entry followed by a series of spaces, the comparison fails and the entry is not found. In order to make the function work, you must explicitly add a NULL termination character, as shown here:
rs.szEntryName = lstEntries.Text & Chr$(0)
That's all it takes.
You may find that no additional information is returned by the RasGetEntryDialParams function. That's because the function returns information from the last successful dial-in that differs from the information stored in the phone book itself. If the information is the same, the returned string will be empty.

 
< previous page page_216 next page >